<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('https://wzc570738205.github.io').hostname,
    root: '/',
    scheme: 'Gemini',
    version: '7.7.0',
    exturl: true,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":true,"show_result":true,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":true,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="本教程只会让你成为Git⽤户，不会让你成为Git专家。很多Git命令只有那些专家才明⽩（事实上我也不明⽩，因为我不是Git专家），但我保证 这些命令可能你⼀辈⼦都不会⽤到。既然Git是⼀个⼯具，就没必要把时间浪费在那些“⾼级”但⼏乎永远不会⽤到的命令上。⼀旦你真的⾮⽤不可了，到时候再 ⾃⾏Google或者请教专家也未迟。如果你是⼀个开发⼈员，想⽤上这个世界上⺫前最先进的分布式版本控制系统，那么，赶">
<meta property="og:type" content="article">
<meta property="og:title" content="Git的使用">
<meta property="og:url" content="https://wzc570738205.github.io/2016/10/20/Git%E7%9A%84%E4%BD%BF%E7%94%A8/index.html">
<meta property="og:site_name" content="王志超的博客">
<meta property="og:description" content="本教程只会让你成为Git⽤户，不会让你成为Git专家。很多Git命令只有那些专家才明⽩（事实上我也不明⽩，因为我不是Git专家），但我保证 这些命令可能你⼀辈⼦都不会⽤到。既然Git是⼀个⼯具，就没必要把时间浪费在那些“⾼级”但⼏乎永远不会⽤到的命令上。⼀旦你真的⾮⽤不可了，到时候再 ⾃⾏Google或者请教专家也未迟。如果你是⼀个开发⼈员，想⽤上这个世界上⺫前最先进的分布式版本控制系统，那么，赶">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://img.smyhvae.com/20180610_1650.png">
<meta property="og:image" content="http://img.smyhvae.com/20180610_1710.png">
<meta property="og:image" content="http://img.smyhvae.com/20180610_1740.png">
<meta property="og:image" content="http://img.smyhvae.com/20180623_1210.png">
<meta property="og:image" content="http://img.smyhvae.com/20180623_1305.png">
<meta property="article:published_time" content="2016-10-20T20:54:57.000Z">
<meta property="article:modified_time" content="2020-01-20T07:16:25.880Z">
<meta property="article:author" content="王志超">
<meta property="article:tag" content="git">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://img.smyhvae.com/20180610_1650.png">

<link rel="canonical" href="https://wzc570738205.github.io/2016/10/20/Git%E7%9A%84%E4%BD%BF%E7%94%A8/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>Git的使用 | 王志超的博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">王志超的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">今天你更博学了吗</h1>
      
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-首页">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-关于">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-标签">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-分类">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-归档">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL3d6YzU3MDczODIwNQ==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wzc570738205.github.io/2016/10/20/Git%E7%9A%84%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/logo.png">
      <meta itemprop="name" content="王志超">
      <meta itemprop="description" content="记录前端的点点滴滴">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="王志超的博客">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          Git的使用
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2016-10-20 20:54:57" itemprop="dateCreated datePublished" datetime="2016-10-20T20:54:57+00:00">2016-10-20</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-01-20 07:16:25" itemprop="dateModified" datetime="2020-01-20T07:16:25+00:00">2020-01-20</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%89%8D%E7%AB%AF%E7%9F%A5%E8%AF%86/" itemprop="url" rel="index">
                    <span itemprop="name">前端知识</span>
                  </a>
                </span>
            </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2016/10/20/Git%E7%9A%84%E4%BD%BF%E7%94%A8/#comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2016/10/20/Git%E7%9A%84%E4%BD%BF%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>本教程只会让你成为Git⽤户，不会让你成为Git专家。很多Git命令只有那些专家才明⽩（事实上我也不明⽩，因为我不是Git专家），但我保证 这些命令可能你⼀辈⼦都不会⽤<br>到。既然Git是⼀个⼯具，就没必要把时间浪费在那些“⾼级”但⼏乎永远不会⽤到的命令上。⼀旦你真的⾮⽤不可了，到时候再 ⾃⾏Google或者请教专家也未迟。如果你是⼀个开发⼈员，想⽤上这个世界上⺫前最先进的分布式版本控制系统，那么，赶快开始学习吧！</p>
<a id="more"></a>
<div class="note success no-icon">
            <p>欢迎加入前端交流群：<a href="//shang.qq.com/wpa/qunwpa?idkey=f528775f242a7c39fe8512383febb8990e621bf97354c2fb82f6832097b7c501" target="_blank" rel="noopener">749539640</a> </p>
          </div>

<h2 id="常见操作"><a href="#常见操作" class="headerlink" title="常见操作"></a>常见操作</h2><h3 id="全局配置用户信息"><a href="#全局配置用户信息" class="headerlink" title="全局配置用户信息"></a>全局配置用户信息</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name &quot;smyhvae&quot;</span><br><span class="line"></span><br><span class="line">git config --global user.email &quot;smyhvae@163.com&quot;</span><br></pre></td></tr></table></figure>


<h2 id="分支的合并"><a href="#分支的合并" class="headerlink" title="分支的合并"></a>分支的合并</h2><h3 id="场景：基于master分支的代码，开发一个新的特性"><a href="#场景：基于master分支的代码，开发一个新的特性" class="headerlink" title="场景：基于master分支的代码，开发一个新的特性"></a>场景：基于master分支的代码，开发一个新的特性</h3><p>如果你直接在master分支上开发这个新特性，是不好的，万一你在开发<code>特性1</code>的时候，领导突然又要叫你去开发<code>特性2</code>，就不好处理了。难道开发的两个特性都提交到master？一会儿提交特性1的commit，一会儿提交特性2的commit？这会导致commit记录很混乱。</p>
<p>所以，我给你的建议做法是：给每个特性都单独建一个的新的分支。</p>
<p>比如说，我专门给<code>特性1</code>建一个分支<code>feature_item_recommend</code>。具体做法如下：</p>
<p>（1）基于master分支，创建一个新的分支，起名为<code>feature_item_recommend</code>：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git checkout -b feature_item_recommend</span><br><span class="line"></span><br><span class="line">Switched to a new branch &#39;feature_item_recommend&#39;</span><br></pre></td></tr></table></figure>

<p>上面这行命令，相当于：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git branch feature_item_recommend    // 创建新的分支</span><br><span class="line"></span><br><span class="line">$ git checkout feature_item_recommend  //切换到新的分支</span><br></pre></td></tr></table></figure>


<p>（2）在新的分支<code>feature_item_recommend</code>上，完成开发工作，并 commit 、push。</p>
<p>（3）将分支<code>feature_item_recommend</code>上的开发进度<strong>合并</strong>到master分支：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git checkout master  //切换到master分支</span><br><span class="line"></span><br><span class="line">$ git merge feature_item_recommend    //将分支 feature_item_recommend 的开发进度合并到 master 分支</span><br></pre></td></tr></table></figure>


<p>合并之后，<code>master</code>分支和<code>feature_item_recommend</code>分支会指向同一个位置。</p>
<p>（3）删除分支<code>feature_item_recommend</code>：</p>
<blockquote>
<p>既然 特性1 开发完了，也放心地提交到master了，那我们就可以将这个分支删除了。</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git branch -d feature_item_recommend</span><br></pre></td></tr></table></figure>

<p>注意，我们当前是处于<code>master</code>分支的位置，来删除<code>feature_item_recommend</code>分支。如果当前是处于<code>feature_item_recommend</code>分支，是没办法删除它自己的。</p>
<p>同理，当我转身去开发<code>特性2</code>的时候，也是采用同样的步骤。</p>
<h3 id="合并分支时，如果存在分叉"><a href="#合并分支时，如果存在分叉" class="headerlink" title="合并分支时，如果存在分叉"></a>合并分支时，如果存在分叉</h3><p><img src="http://img.smyhvae.com/20180610_1650.png" alt=""></p>
<p>比如说上面这张图中，最早的时候，master分支是位于<code>C2</code>节点。我基于<code>C2</code>节点，new出一个新的分支<code>iss53</code>，我在<code>iss53</code>上提交了好几个commit。</p>
<p>现在，我准备把<code>iss53</code>上的几个commit合并到master上，此时发现，master分支已经前进到C4了。那该怎么合并呢？</p>
<p>合并的命令仍然是：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git checkout master</span><br><span class="line"></span><br><span class="line">$ git merge iss53</span><br></pre></td></tr></table></figure>

<p><strong>解释</strong>：</p>
<p>这次合并的实现，并不同于简单的并入方式。这一次，我的开发历史是从更早的地方开始分叉的。</p>
<p>由于当前 master 分支所指向的commit (C4)并非想要并入分支（iss53）的直接祖先，Git 不得不进行一些处理。就此例而言，Git 会用两个分支的末端（C4 和C5）和它们的共同祖先（C2）进行一次简单的三方合并计算。</p>
<p>Git 没有简单地把分支指针右移，而是对三方合并的结果作一新的快照，并自动创建一个指向它的commit（C6）（如下图所示）。我们把这个特殊的commit 称作合并提交（mergecommit），因为它的祖先不止一个。</p>
<p>值得一提的是Git 可以自己裁决哪个共同祖先才是最佳合并基础；这和CVS 或Subversion（1.5 以后的版本）不同，它们需要开发者手工指定合并基础。所以此特性让Git 的合并操作比其他系统都要简单不少。</p>
<p><img src="http://img.smyhvae.com/20180610_1710.png" alt=""></p>
<h3 id="解决合并时发生的冲突"><a href="#解决合并时发生的冲突" class="headerlink" title="解决合并时发生的冲突"></a>解决合并时发生的冲突</h3><p><img src="http://img.smyhvae.com/20180610_1740.png" alt=""></p>
<p>如果 feature1和feature2修改的是同一个文件中<strong>代码的同一个位置</strong>，那么，把feature1合并到feature2时，就会产生冲突。这个冲突需要人工解决。步骤如下：</p>
<p>（1）手动修改文件：手动修改冲突的那个文件，决定到底要用哪个分支的代码。</p>
<p>（2）git add：解决好冲突后，输入<code>git status</code>，会提示<code>Unmerged paths</code>。这个时候，输入<code>git add</code>即可，表示：<strong>修改冲突成功，加入暂存区</strong>。</p>
<p>（3）git commit 提交。</p>
<p>然后，我们可以继续把 feature1 分支合并到 master分支，最后删除feature1、feature2。</p>
<p><strong>注意</strong>：两个分支的同一个文件的不同地方合并时，git会自动合并，不会产生冲突。</p>
<p>比如分支feture1对index.html原来的第二行之前加入了一段代码。<br>分支feature2对index.html在原来的最后一行的后面加入了一段代码。<br>这个时候在对两个分支合并，git不会产生冲突，因为两个分支是修改同一文件的不同位置。<br>git自动合并成功。不管是git自动合并成功，还是在人工解决冲突下合并成功，提交之前，都要对代码进行测试。</p>
<h2 id="日常操作积累"><a href="#日常操作积累" class="headerlink" title="日常操作积累"></a>日常操作积累</h2><h3 id="修改密码（曲线救国）"><a href="#修改密码（曲线救国）" class="headerlink" title="修改密码（曲线救国）"></a>修改密码（曲线救国）</h3><blockquote>
<p>网上查了很久，没找到答案。最终，在cld童鞋的提示下，采取如下方式进行曲线救国。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 设置当前仓库的用户名为空</span></span><br><span class="line">git config  user.name <span class="string">""</span></span><br></pre></td></tr></table></figure>


<p>然后，当我们再输入<code>git pull</code>等命令行时，就会被要求重新输入<em>新的</em>账号密码。此时，密码就可以修改成功了。最后，我们还要输入如下命令，还原当前仓库的用户名：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config user.name &quot;smyhvae&quot;</span><br></pre></td></tr></table></figure>


<h3 id="修改已经push的某次commit的作者信息"><a href="#修改已经push的某次commit的作者信息" class="headerlink" title="修改已经push的某次commit的作者信息"></a>修改已经push的某次commit的作者信息</h3><p>已经push的记录，如果要修改作者信息的话，只能 通过–force命令。我反正是查了很久，但最终还是不敢用公司的仓库尝试。</p>
<p>参考链接：</p>
<ul>
<li><span class="exturl" data-url="aHR0cHM6Ly9zZWdtZW50ZmF1bHQuY29tL3EvMTAxMDAwMDAwNjk5OTg2MQ==" title="https://segmentfault.com/q/1010000006999861">git 修改已提交的某一次的邮箱和用户信息<i class="fa fa-external-link"></i></span></li>
</ul>
<p>看最后一条答案。</p>
<ul>
<li><span class="exturl" data-url="aHR0cDovL2JhdXJpbmUuZ2l0aHViLmlvLzIwMTUvMDgvMjIvZ2l0X3VwZGF0ZV9hdXRob3IuaHRtbA==" title="http://baurine.github.io/2015/08/22/git_update_author.html">修改 git repo 历史提交的 author<i class="fa fa-external-link"></i></span></li>
</ul>
<h3 id="将-branch1的某个commit1合并到branch2当中"><a href="#将-branch1的某个commit1合并到branch2当中" class="headerlink" title="将 branch1的某个commit1合并到branch2当中"></a>将 <code>branch1</code>的某个<code>commit1</code>合并到<code>branch2</code>当中</h3><p>切换到branch2中，然后执行如下命令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git cherry-pick commit1</span><br></pre></td></tr></table></figure>


<h3 id="修改GitHub已提交的用户名和邮箱"><a href="#修改GitHub已提交的用户名和邮箱" class="headerlink" title="修改GitHub已提交的用户名和邮箱"></a>修改GitHub已提交的用户名和邮箱</h3><p>参考链接：（亲测有效）</p>
<ul>
<li><p><span class="exturl" data-url="aHR0cHM6Ly9jbG91ZC50ZW5jZW50LmNvbS9kZXZlbG9wZXIvYXJ0aWNsZS8xMzUyNjIz" title="https://cloud.tencent.com/developer/article/1352623">修改Git全部Commit提交记录的用户名Name和邮箱Email<i class="fa fa-external-link"></i></span></p>
</li>
<li><p><span class="exturl" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3l1c3Vmb2x1OS9hcnRpY2xlL2RldGFpbHMvNTM3MDYyNjk=" title="https://blog.csdn.net/yusufolu9/article/details/53706269">Mac 运行sh文件，也就是传说中的shell脚本<i class="fa fa-external-link"></i></span></p>
</li>
</ul>
<h2 id="git客户端推荐"><a href="#git客户端推荐" class="headerlink" title="git客户端推荐"></a>git客户端推荐</h2><p>市面上的Git客户端我基本都用过了，我最推荐的一款Git客户端是：<span class="exturl" data-url="aHR0cHM6Ly93d3cuZ2l0LXRvd2VyLmNvbQ==" title="https://www.git-tower.com">Tower<i class="fa fa-external-link"></i></span> 或者 <span class="exturl" data-url="aHR0cHM6Ly9naXQtZm9yay5jb20=" title="https://git-fork.com">Fork<i class="fa fa-external-link"></i></span>。</p>
<ul>
<li>GitUp：<span class="exturl" data-url="aHR0cHM6Ly9naXR1cC5jby8=" title="https://gitup.co/">https://gitup.co/<i class="fa fa-external-link"></i></span></li>
</ul>
<p>网上看了下Git客户端的推荐排名：</p>
<p><img src="http://img.smyhvae.com/20180623_1210.png" alt=""></p>
<p><strong>SmartGit</strong>：</p>
<p>商业用途收费， 个人用户免费：<br>s<br><img src="http://img.smyhvae.com/20180623_1305.png" alt=""></p>
<h2 id="推荐书籍"><a href="#推荐书籍" class="headerlink" title="推荐书籍"></a>推荐书籍</h2><ul>
<li>《pro.git中文版》</li>
</ul>
<h2 id="推荐连接"><a href="#推荐连接" class="headerlink" title="推荐连接"></a>推荐连接</h2><ul>
<li><span class="exturl" data-url="aHR0cHM6Ly93d3cubGlhb3h1ZWZlbmcuY29tL3dpa2kvODk2MDQzNDg4MDI5NjAw" title="https://www.liaoxuefeng.com/wiki/896043488029600">廖雪峰git<i class="fa fa-external-link"></i></span></li>
<li><span class="exturl" data-url="aHR0cHM6Ly93d3cuY25ibG9ncy5jb20vd2FuZ2lxbmdwZWk1NTcvcC82MDU2NjI0Lmh0bWw=" title="https://www.cnblogs.com/wangiqngpei557/p/6056624.html">聊下git pull –rebase<i class="fa fa-external-link"></i></span></li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/git/" rel="tag"># git</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item"></div>
      <div class="post-nav-item">
    <a href="/2016/12/10/html%E6%A0%87%E7%AD%BE%E4%B8%8B/" rel="next" title="html标签下">
      html标签下 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#常见操作"><span class="nav-number">1.</span> <span class="nav-text">常见操作</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#全局配置用户信息"><span class="nav-number">1.1.</span> <span class="nav-text">全局配置用户信息</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#分支的合并"><span class="nav-number">2.</span> <span class="nav-text">分支的合并</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#场景：基于master分支的代码，开发一个新的特性"><span class="nav-number">2.1.</span> <span class="nav-text">场景：基于master分支的代码，开发一个新的特性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#合并分支时，如果存在分叉"><span class="nav-number">2.2.</span> <span class="nav-text">合并分支时，如果存在分叉</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解决合并时发生的冲突"><span class="nav-number">2.3.</span> <span class="nav-text">解决合并时发生的冲突</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#日常操作积累"><span class="nav-number">3.</span> <span class="nav-text">日常操作积累</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#修改密码（曲线救国）"><span class="nav-number">3.1.</span> <span class="nav-text">修改密码（曲线救国）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改已经push的某次commit的作者信息"><span class="nav-number">3.2.</span> <span class="nav-text">修改已经push的某次commit的作者信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#将-branch1的某个commit1合并到branch2当中"><span class="nav-number">3.3.</span> <span class="nav-text">将 branch1的某个commit1合并到branch2当中</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改GitHub已提交的用户名和邮箱"><span class="nav-number">3.4.</span> <span class="nav-text">修改GitHub已提交的用户名和邮箱</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#git客户端推荐"><span class="nav-number">4.</span> <span class="nav-text">git客户端推荐</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#推荐书籍"><span class="nav-number">5.</span> <span class="nav-text">推荐书籍</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#推荐连接"><span class="nav-number">6.</span> <span class="nav-text">推荐连接</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="王志超"
      src="/images/logo.png">
  <p class="site-author-name" itemprop="name">王志超</p>
  <div class="site-description" itemprop="description">记录前端的点点滴滴</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">19</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL3d6YzU3MDczODIwNQ==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;wzc570738205"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly93d3cuY25ibG9ncy5jb20vd2FuZ3poaWNoYW8v" title="博客园 → https:&#x2F;&#x2F;www.cnblogs.com&#x2F;wangzhichao&#x2F;"><i class="fa fa-fw fa-globe"></i>博客园</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cDovL21haWwucXEuY29tL2NnaS1iaW4vcW1fc2hhcmU/dD1xbV9tYWlsbWUmZW1haWw9eHJHOHBmLXo5dkgzLTRhM3RfaWxxYXM=" title="E-Mail → http:&#x2F;&#x2F;mail.qq.com&#x2F;cgi-bin&#x2F;qm_share?t&#x3D;qm_mailme&amp;email&#x3D;xrG8pf-z9vH3-4a3t_ilqas"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
      <span class="links-of-author-item">
        <a href="//shang.qq.com/wpa/qunwpa?idkey=f528775f242a7c39fe8512383febb8990e621bf97354c2fb82f6832097b7c501" target="_blank" rel="noopener" title="QQ群 → &#x2F;&#x2F;shang.qq.com&#x2F;wpa&#x2F;qunwpa?idkey&#x3D;f528775f242a7c39fe8512383febb8990e621bf97354c2fb82f6832097b7c501"><i class="fa fa-fw fa-qq"></i>QQ群</a>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cDovL3dhbmd6Yy53YW5nL3dlYnNvY2tldC8=" title="websocket → http:&#x2F;&#x2F;wangzc.wang&#x2F;websocket&#x2F;"><i class="fa fa-fw fa-comments"></i>websocket</span>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 2015 – 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">王志超</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>

<script src="/js/bookmark.js"></script>




  




  
<script src="/js/local-search.js"></script>









<script>
if (document.querySelectorAll('div.pdf').length) {
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/pdfobject@2/pdfobject.min.js', () => {
    document.querySelectorAll('div.pdf').forEach(element => {
      PDFObject.embed(element.getAttribute('target'), element, {
        pdfOpenParams: {
          navpanes: 0,
          toolbar: 0,
          statusbar: 0,
          pagemode: 'thumbs',
          view: 'FitH'
        },
        PDFJS_URL: '/lib/pdf/web/viewer.html',
        height: element.getAttribute('height') || '700px'
      });
    });
  }, window.PDFObject);
}
</script>




  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el: '#valine-comments',
      verify: false,
      notify: false,
      appId: '9fgm6JVbw8PrOlvp7LfsKjsh-gzGzoHsz',
      appKey: 'LReLvzSwPnBOAz5LiIgJsiDO',
      placeholder: "说点什么吧",
      avatar: 'mm',
      meta: guest,
      pageSize: '10' || 10,
      visitor: false,
      lang: 'zh-cn' || 'zh-cn',
      path: location.pathname,
      recordIP: false,
      serverURLs: ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
